﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>验收完成</title>
    <link href="~/Content/Css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="~/Content/Css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="~/Content/Css/animate.css" rel="stylesheet">
    <link href="~/Content/Css/style.css?v=4.1.0" rel="stylesheet">
    <link href="~/Content/Css/plugins/iCheck/custom.css" rel="stylesheet">
    <style>
        .ibox {
            margin-bottom: 0px;
        }

        .ibox-content {
            padding: 15px 20px 0px 20px;
        }

        .ibox .open > .dropdown-menu {
            left: 0;
            right: 0;
        }


        .right-border {
            border-right: 1px solid #ccc;
            padding-right: 5px;
        }

        .border {
            border: 1px solid #ccc;
            border-left: none;
            border-right: none;
            padding: 5px 0;
            height: 34px;
        }

        .border2 {
            border: 1px solid #ccc;
            border-left: none;
            border-right: none;
            border-top: none;
            padding: 5px 0;
            height: 34px;
        }

        .inline i {
            padding-left: 5px;
        }

        .inp {
            width: 177px;
            height: 26px;
            padding: 5px 4px;
            display: inline;
        }

        .inp-min {
            width: 82.5px;
            height: 26px;
            padding: 2px 4px;
            display: inline;
        }

        .lab {
            margin-bottom: 5px;
            font-weight: 800;
            cursor: default;
            width: 60px;
            text-align: center;
        }

        .sel {
            width: 100px;
            height: 25px;
            padding: 1px 4px;
            display: inline;
            font-size: 15px;
        }

        .sel-min {
            width: 82.5px;
            height: 25px;
            padding: 1px 4px;
            display: inline;
            font-size: 15px;
        }

        .mybtn-group {
            margin-top: -4px;
        }

        .columns-right {
            height: 39px;
        }

            .columns-right button {
                padding: 1px 5px;
                font-size: 15px;
                line-height: 1.5;
            }
    </style>
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>签约完成</h5>
            </div>
            <div class="ibox-content">
                <div class="col-sm-12">
                    <form id="mainForm">

                        <input id="repeatPhone" name="repeatPhone" type="hidden" value="false" />
                        <div id="toolbar">
                            <label class="lab">装修公司</label>
                            <select class="form-control sel" id="DecorationCompanyID" name="DecorationCompanyID">
                                <option value="0">全部</option>
                            </select>

                            <label class="lab">中介名称</label>
                            <select class="form-control sel-min" id="IntermediaryID" name="IntermediaryID">
                                <option value="0">全部</option>
                            </select>
                            <label class="lab">装修顾问</label>
                            <select class="form-control sel-min" id="DecorationConsultantName" name="DecorationConsultantName">
                                <option value="0">全部</option>
                            </select>
                            <label class="lab">渠道人员</label>
                            <select class="form-control sel-min" id="OriginStaffID" name="OriginStaffID">
                                <option value="0">全部</option>
                            </select>
                            <label class="lab">签约总款</label>
                            <input type="number" class="form-control sel-min" id="beginPrice" name="beginPrice">
                            <label class="lab" style="width:5px">-</label>
                            <input type="number" class="form-control sel-min" id="endPrice" name="endPrice">
                            @*<label class="lab">报备日期</label>*@
                            <select class="form-control sel-min" style="width:125px;" id="dataType" name="dataType">
                                <option value="0">报备日期</option>
                                <option value="1">报备审核日期</option>
                                <option value="2">量尺到店日期</option>
                                <option value="3">定金完成日期</option>
                                <option value="4">首付完成日期</option>
                                <option value="5">验收日期</option>
                            </select>
                            <div class="btn-group mybtn-group" style="padding-top:5px;">
                                <button class="btn btn-primary btn-xs" style="font-size:14px" type="button" onclick="QuickBtn(this)" value="0" tradeName="0">全部</button>
                                <button class="btn btn-primary btn-xs down" style="font-size:14px" type="button">
                                    <i class="fa fa-sort-down"></i>
                                </button>
                                <ul class="dropdown-menu">
                                    <li>
                                        <a class="font-bold" value="0" onclick="QuickBtn(this)">今日</a>
                                    </li>
                                    <li>
                                        <a class="font-bold" value="3" onclick="QuickBtn(this)">近三日</a>
                                    </li>
                                    <li>
                                        <a class="font-bold" value="7" onclick="QuickBtn(this)">近七日</a>
                                    </li>
                                    <li>
                                        <a class="font-bold" value="15" onclick="QuickBtn(this)">近十五日</a>
                                    </li>
                                </ul>
                                <input type="text" class="form-control inp" style="width:99px;" id="beginDate" name="beginDate" readonly="readonly" value="@DateTime.Now.AddMonths(-3).ToString("yyyy-MM-dd")">
                                <input type="text" class="form-control inp" style="width:99px;margin-left:-3px;" id="endDate" name="endDate" readonly="readonly" value="@DateTime.Now.ToString("yyyy-MM-dd")">
                            </div>
                            <div class="btn-group mybtn-group" style="padding-top:5px;margin-top: -7px;">
                                <button class="btn btn-white btn-xs" style="font-size: 14px;" type="submit">查询</button>
                                <button class="btn btn-primary btn-xs" style="font-size: 14px;" type="reset">清空</button>
                            </div>
                            <div id="searchSeniorDiv">
                                <div>

                                </div>
                            </div>
                        </div>
                        <input id="orderBy" name="orderBy" type="hidden" />
                        <input id="orderByType" name="orderByType" type="hidden" />
                    </form>
                </div>

                <div class="row row-lg">
                    <div class="col-sm-12">
                        <table id="table"></table>
                    </div>
                </div>
            </div>
        </div>
        @* 用来传递消息的隐藏域 *@
        <input id="handle_status" value="" hidden="hidden">
    </div>


    <!-- 全局js -->
    <script type="text/javascript" src="~/Scripts/jquery.min.js?v=2.1.4"></script>
    <script type="text/javascript" src="~/Scripts/bootstrap.min.js?v=3.3.6"></script>
    <!-- 自定义js -->
    <script type="text/javascript" src="~/Scripts/content.js?v=1.0.0"></script>
    <script type="text/javascript" src="~/Areas/Decoration/Scripts/GeneralCondition.js"></script>
    <script type="text/javascript" src="~/Areas/Decoration/Scripts/RunningGlobal.js"></script>
    <script type="text/javascript" src="~/Areas/Decoration/Scripts/DecorationRunningUpdate.js"></script>
    <!-- Bootstrap table -->
    <script type="text/javascript" src="~/Scripts/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script type="text/javascript" src="~/Scripts/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>

    <!-- layer javascript -->
    <script type="text/javascript" src="~/Scripts/plugins/layer/layer.min.js"></script>
    <script src="~/Scripts/plugins/layer/laydate/laydate.js"></script>

    <!-- 查看权限 -->
    <script src="~/Scripts/loginmodel.js"></script>

    <script type="text/javascript">
        laydate({
            elem: '#beginDate',
            format: 'YYYY-MM-DD', // 分隔符可以任意定义，该例子表示只显示年月
            festival: true, //显示节日
            max: '2099-01-01 00:00:00', //设定最小日期为当前日期
            min: '2010-01-01 00:00:00', //最大日期
            choose: function (datas) { //选择日期完毕的回调
                //alert('得到：' + datas);
            }
        });
        laydate({
            elem: '#endDate',
            start: laydate.now(),
            format: 'YYYY-MM-DD', // 分隔符可以任意定义，该例子表示只显示年月
            festival: true, //显示节日
            max: '2099-01-01 00:00:00', //设定最小日期为当前日期
            min: '2010-01-01 00:00:00', //最大日期
            choose: function (datas) { //选择日期完毕的回调
                //alert('得到：' + datas);
            }
        });
        $(function () {
            initTable();
        });
        $("#mainForm").submit(function () {
            $table.bootstrapTable('refresh');
            return false;
        });
        var $table = $('#table');
        function initTable() {
            $table.bootstrapTable({
                url: '/DecorationRunnings/GetListFinish', //获取报备信息
                method: 'post',                     //数据请求方式
                striped: true,                      //是否显示行间隔色
                cache: false,                       //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
                pagination: true,                   //是否启用分页
                sidePagination: 'server',           //在服务器端分页
                queryParams: queryParams,           //传递参数
                pageNumber: 1,                      //初始化加载第一页，默认第一页
                pageSize: 20,                       //每页的记录行数（*）
                pageList: [10, 20, 30, 40, 50],     //可供选择的每页的行数（*）
                clickToSelect: true,                //是否启用点击选中行
                //toolbar: "#tableToolBar",
                height: getHeight(),
                columns: [{
                    width: 38,
                    field: 'selected',
                    checkbox: true,
                }, {
                    title: '行号',
                    align: 'center',
                    formatter: function (value, row, index) { return index + 1; }
                }, {
                    field: 'id',
                    title: '流水号',
                    align: 'center'
                }, {
                    field: 'decorationCompanyName',
                    title: '装修公司名称',
                    align: 'center'
                }, {
                    field: 'intermediaryName',
                    title: '中介名称',
                    align: 'center'
                }, {
                    field: 'userName',
                    title: '经纪人姓名',
                    align: 'center'
                }, {
                    field: 'userPhone',
                    title: '经纪人电话',
                    align: 'center'
                }, {
                    field: 'customerName',
                    title: '客户姓名',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var temp = '';
                        if (isAuthority('259')) {
                            temp += [
                            '<a class="customername" href="javascript:void(0)" title="修改姓名">',
                            '<i class="glyphicon glyphicon-edit"></i>',
                            '</a>  '].join('');
                        }

                        temp += [
                            '<label>',
                            value,
                            '</label>'
                        ].join('');

                        return temp;
                    },
                    events: operateEvents
                }, {
                    field: 'customerPhone',
                    title: '客户电话',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var temp = '';
                        if (isAuthority('260')) {
                            temp += [
                            '<a class="customerphone" href="javascript:void(0)" title="修改电话">',
                            '<i class="glyphicon glyphicon-edit"></i>',
                            '</a>  '].join('');
                        }

                        temp += [
                            '<label>',
                            value,
                            '</label>'
                        ].join('');

                        return temp;
                    },
                    events: operateEvents
                }, {
                    field: 'customerAddress',
                    title: '客户地址',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var temp = '';
                        if (isAuthority('261')) {
                            temp += [
                            '<a class="customeraddress" href="javascript:void(0)" title="修改地址">',
                            '<i class="glyphicon glyphicon-edit"></i>',
                            '</a>  '].join('');
                        }

                        temp += [
                            '<label>',
                            value,
                            '</label>'
                        ].join('');

                        return temp;
                    },
                    events: operateEvents
                }, {
                    field: 'filingTime',
                    title: '报备时间',
                    align: 'center'
                }, {
                    field: 'bandSawTime',
                    title: '带看时间',
                    align: 'center'
                }, {
                    field: 'totalPrice',
                    title: '签约总款',
                    align: 'center'
                }, {
                    field: 'area',
                    title: '签约面积',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var temp = '';
                        if (isAuthority('262')) {
                            temp += [
                            '<a class="area" href="javascript:void(0)" title="修改面积">',
                            '<i class="glyphicon glyphicon-edit"></i>',
                            '</a>  '].join('');
                        }

                        temp += [
                            '<label>',
                            value,
                            '</label>'
                        ].join('');

                        return temp;
                    },
                    events: operateEvents
                }, {
                    field: 'remark',
                    title: '备注',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var temp = '';
                        if (isAuthority('263')) {
                            temp += [
                            '<a class="remark" href="javascript:void(0)" title="修改备注">',
                            '<i class="glyphicon glyphicon-edit"></i>',
                            '</a>  '].join('');
                        }

                        temp += [
                            '<label>',
                            value,
                            '</label>'
                        ].join('');

                        return temp;
                    },
                    events: operateEvents
                }, {
                    field: 'originStaffName',
                    title: '渠道人员',
                    align: 'center'
                }, {
                    field: 'starTarget',
                    title: '星标',
                    align: 'center',
                    formatter: FormatterstarTarget
                }, {
                    field: 'state',
                    title: '状态',
                    align: 'center',
                    formatter: FormatterState
                }, {
                    title: '操作员',
                    align: 'center',
                    formatter: FormatterOperator
                }, {
                    title: '带看单管理',
                    align: 'center',
                    formatter: PictureManagementFormatter
                }, {
                    title: '成交协议',
                    align: 'center',
                    formatter: PictureManagement2Formatter
                },
                //{
                //    field: 'decorationConsultantName',
                //    title: '装修顾问',
                //    align: 'center'
                //},
                {
                    field: 'id',
                    title: '取消订单',
                    align: 'center',
                    formatter: FormatterstarTargetReturn
                }
                ],
                onLoadSuccess: function (data) {
                    if (data.total == 0) {
                        $(".ibox-content").css("padding-bottom", "22px");
                    } else {
                        $(".ibox-content").css("padding-bottom", "4px");
                    }
                }
            });
        }

        //查询的参数
        var queryParams = function (params) {
            var temp = {
                pageSize: params.limit,                             //行数
                pageIndex: (params.offset / params.limit) + 1,      //页码
                search: $('#searchKey').val(),                       //查询内容
                dataType: $("#dataType").val(),
                beginDate: $("#beginDate").val(),
                endDate: $("#endDate").val(),
                beginPrice: $("#beginPrice").val(),
                endPrice: $("#endPrice").val(),
                DecorationCompanyID: $("#DecorationCompanyID").val(),
                IntermediaryID: $("#IntermediaryID").val(),
                DecorationConsultantName: $("#DecorationConsultantName").find("option:selected").text(),
                OriginStaffID: $("#OriginStaffID").val()
            };
            //console.info(temp);
            return temp;
        };

        //刷新表格数据
        var refreshTable = function () {
            $table.bootstrapTable('refresh');
        }

        //自定义的列事件
        function operateFormatter(value, row, index) {
            return [
                '<a class="edit" href="javascript:void(0)" title="编辑">',
                '<i class="glyphicon glyphicon-edit"></i>',
                '</a>  ',
                '<a class="remove" href="javascript:void(0)" title="删除">',
                '<i class="glyphicon glyphicon-remove"></i>',
                '</a>'
            ].join('');
        }

        window.operateEvents = {
            'click .edit': function (e, value, row, index) {

            },
            'click .remove': function (e, value, row, index) {

            },
            'click .customername': function (e, value, row, index) {
                customerNameEdit(row['id']);//客户姓名
            },
            'click .customerphone': function (e, value, row, index) {
                customerPhoneEdit(row['id']);//客户电话
            },
            'click .remark': function (e, value, row, index) {
                remarkEdit(row['id']);//备注
            },
            'click .area': function (e, value, row, index) {
                areaList(row['id']);//面积
            },
            'click .customeraddress': function (e, value, row, index) {
                addressaList(row['id']);//地址
            }
        };
        //操作员明细
        function FormatterOperator(value, row, index) {
            return [
                '<a class="kv-file-zoom btn btn-xs btn-primary" href="javascript:void(0)"  onclick="OperatorDetail(' + row.id + ')">',
                '操作员',
                '</a>  ',
            ].join('');
        }
        function OperatorDetail(id) {
            parent.layer.open({
                type: 2,
                title: '操作员明细',
                shadeClose: false,
                shade: 0.4,
                area: ['300px', '300px'],
                content: '/Decoration/DecorationRunnings/OperatorDetails?Id=' + id,
                end: function () {
                    refreshTable();
                }
            });
        }        
        function FormatterstarTargetReturn(value, row, index) {
            if (isAuthority('270')) {
                return [
                  '<a href="javascript:void(0)"  onclick="Return(' + value + ',' + row.state + ');">',
                  '<i">取消订单</i>',
                  '</a>  '
                ].join('');
            }
        }
        function Return(id, state) {
            layer.open({
                title: "申请取消订单备注",
                area: ["600px", "200px"],
                content: "<form class='form-horizontal m-t' id='mainForm'><label class='col-xs-3 control-label'>取消订单备注：</label><div class='col-xs-9'><textarea id='Returnremark' name='Returnremark' class='form-control' row='3'></textarea></div></form>",
                btn: ['确认', '取消'],
                shadeClose: false,
                yes: function () {
                    //进行ajax传值
                    $.ajax({
                        url: " /Decoration/DecorationRunnings/Return",
                        type: "post",
                        dataType: "json",
                        data: { "id": id, "remark": $("#Returnremark").val(), "state": state },
                        success: function (data) {
                            //Info,Success,Warning,Error
                            var type = data.type;
                            if (type == 1) {
                                layer.msg(data.content, { icon: 6, time: 2000 },
                                    function () {
                                        var index = parent.layer.getFrameIndex(window.name);
                                        parent.layer.close(index);
                                        refreshTable();
                                    });

                            } else {
                                layer.msg(data.content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, no: function () {

                }
            });
        }
    </script>
</body>
</html>
